<?
require_once("mvc/action/Action.php");
require_once("cms/gallery/om/GalleryPeer.php");

class EditAction extends Action {

    private $log;

    public function __construct() {
        $this->log =& LoggerManager::getLogger("EditAction");
    }

    public function execute(ActionConfig &$mapping, &$form, Request &$request, Response &$response) {

        if($form->getGallery()->getGalleryId() > 0) {
            $gallery = GalleryPeer::retrieveByPk($form->getGallery()->getGalleryId());
            if(!is_null($gallery)) {

                $form->setGallery($gallery);

            } else {
                $this->log->error("No gallery found with id {$form->getGallery()->getGalleryId()}.");
                $form->getGallery()->setGalleryId("");
            }
        }

        return $mapping->findForward("success");

    }

}
?>